import React from 'react';
import { Form, Input, Button ,message} from 'antd'
import service from '../../../api/index';
import { useNavigate } from 'react-router-dom'
interface Props { }
function Swiperadd(props: Props) {
    const navigate = useNavigate();
    const onFinish = async (values: any) => {

        console.log('新增轮播图:', values);
        //发起添加请求
        var res = await service.banner.banner_add(values)
        if (res.data.code == 200) {
            message.success('插入成功')
            console.log(res);
            navigate("/index/Swiper");
        }else {
            message.success('插入失败')
        }
    };
    return (
        <div className='Swiperadd'>
            <Form
                className='Swiper_add'
                name="basic"
                onFinish={onFinish}
            >
                <Form.Item
                    label="link"
                    name="link"
                    rules={[{ required: true, message: '请输入链接!' }]}
                >
                    <Input />
                </Form.Item>

                <Form.Item
                    label="alt"
                    name="alt"
                    rules={[{ required: true, message: '请输入提示!' }]}
                >
                    <Input />
                </Form.Item>
                <Form.Item
                    label="img/base64"
                    name='img'
                    rules={[{ required: true, message: '请选择图片' }]}>
                    <Input />
                </Form.Item>
                <Form.Item>
                    <Button type="primary" htmlType="submit">
                        提交
                    </Button>
                </Form.Item>
            </Form>
        </div>
    );
}

export default Swiperadd;